<?php
if (! defined ( 'BASEPATH' )) {
	exit ( 'No direct script access allowed' );
}

/**
 *用户模块操作
 *@author 王春林
 */
class login_model extends CI_Model {
	function __construct() {
		parent::__construct ();
	}
	/**
	 *用户注册
	 *@param $user
	 */
	function regist($user) {
		$this->db->insert ( 'wanwan_enum_user', $user );
		$userId = $this->db->insert_id();
		$user['userId'] = $userId;
		$this->session->set_userdata($user);
	}
	/**
	 *用户登录
	 *@param $username	$password
	 *@return true/false
	 */
	function user_login($username, $password) {
		$this->db->select('userId,userIcon,nickName,userBigIcon');
		$this->db->where ( 'email', $username );
		$this->db->where ( 'loginPassword', $password );
		$rs = $this->db->get ( 'wanwan_enum_user' );
		
		return $rs->row_array ();
	}
	/**
	 *判断用户名是否存在
	 *@param $username	$password
	 *@return int
	 */
	function isuse($email) {
		$this->db->where ( 'email', $email );
		$rs = $this->db->get ( 'wanwan_enum_user' );
		$rs->result ();
		return $rs->num_rows ();
	}
}
?>